module.exports = app => {
  const path = require('path')
  const log4js = require('log4js')
  log4js.configure({
    appenders: {
      production: {
        type: 'dateFile',
        filename: path.join(__dirname, '../logs/file'),
        alwaysIncludePattern: true,
        pattern: 'yyyy-MM-dd.log'
      }
    },
    categories: {
      default: { appenders: ['production'], level: 'debug' }
    }
  })

  const logger = log4js.getLogger()
  app.use(log4js.connectLogger(logger, { level: log4js.levels.INFO }))
  app.use(log4js.connectLogger(logger, { level: log4js.levels.WARN }))
  app.use(log4js.connectLogger(logger, { level: log4js.levels.ERROR }))

  logger.trace('This is a Log4js-Test')
  logger.debug('We Write Logs with log4js')
  logger.info('You can find logs-files in the log-dir')
  logger.warn('log-dir is a configuration-item in the log4js.json')
  logger.error('In This Test log-dir is : \'./logs/log_test/\'')
}
